import unittest
# 导入生成报告的插件
from HTMLTestRunner import HTMLTestRunner
from time import strftime
# 加载当前目录中的所有测试模块，将测试用例放入到测试套件
suite = unittest.defaultTestLoader.discover('.')

if __name__ == '__main__':
    # 运行测试套件
    # runner = unittest.TextTestRunner()
    # runner.run(suite)
    # 执行测试套件，写入到测试报告文件
    with open(f'../report/{strftime("%Y_%m_%d_%H_%M_%S")}.html', mode='wb') as fw:
        # 创建测试报告运行器
        runner = HTMLTestRunner(fw, title='测试报告', description='测试报告描述')
        # 运行测试套件
        runner.run(suite)


